from fastapi import APIRouter, Depends
from typing import List
from datetime import datetime, timedelta
from .auth import get_current_active_user, User

router = APIRouter(
    prefix="/api/executions",
    tags=["执行记录"],
    responses={404: {"description": "Not found"}},
)

@router.get("/recent")
async def get_recent_executions(current_user: User = Depends(get_current_active_user)):
    """获取最近的执行记录"""
    # 这里是示例数据，实际应该从数据库获取
    now = datetime.now()
    return [
        {
            "processName": "财务数据处理",
            "startTime": (now - timedelta(minutes=30)).isoformat(),
            "endTime": (now - timedelta(minutes=25)).isoformat(),
            "status": "success"
        },
        {
            "processName": "客户数据导入",
            "startTime": (now - timedelta(hours=2)).isoformat(),
            "endTime": (now - timedelta(hours=1, minutes=55)).isoformat(),
            "status": "success"
        },
        {
            "processName": "周报生成",
            "startTime": (now - timedelta(hours=4)).isoformat(),
            "endTime": (now - timedelta(hours=3, minutes=55)).isoformat(),
            "status": "success"
        }
    ] 